import sys
from PySide6.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, 
                               QPushButton, QLabel, QHBoxLayout, QFrame)
from PySide6.QtCore import Qt
from PySide6.QtGui import QFont, QPixmap
from qt_material import apply_stylesheet

# 导入现有的工具
from tools.TextJoinerUI import TextJoinerUI
from tools.WordTableGeneratorUI import WordTableGeneratorUI
from RecruitmentSystem import RecruitmentSystem


class MainWindowUI(QMainWindow):
    def __init__(self):
        super().__init__()
        self.initUI()
        
    def initUI(self):
        self.setWindowTitle('人事处工具集')
        self.setGeometry(100, 100, 600, 400)
        
        # 创建中央部件
        central_widget = QWidget()
        self.setCentralWidget(central_widget)
        main_layout = QVBoxLayout(central_widget)
        
        # 标题
        title_label = QLabel("玉师人事处工具集")
        title_label.setAlignment(Qt.AlignCenter)
        title_font = QFont()
        title_font.setPointSize(24)
        title_font.setBold(True)
        title_label.setFont(title_font)
        main_layout.addWidget(title_label)
        
        # 分隔线
        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        main_layout.addWidget(line)
        
        # 工具按钮区域
        tools_layout = QVBoxLayout()
        tools_layout.setAlignment(Qt.AlignCenter)
        
        # 文本连接工具按钮
        text_joiner_btn = QPushButton("文本连接/拆分工具")
        text_joiner_btn.setFixedSize(300, 50)
        text_joiner_btn.clicked.connect(self.open_text_joiner)
        tools_layout.addWidget(text_joiner_btn)
        
        # Word表格生成工具按钮
        word_table_btn = QPushButton("席位牌生成工具")
        word_table_btn.setFixedSize(300, 50)
        word_table_btn.clicked.connect(self.open_word_table)
        tools_layout.addWidget(word_table_btn)
        
        # 招聘管理系统按钮
        # recruitment_system_btn = QPushButton("招聘管理系统")
        # recruitment_system_btn.setFixedSize(300, 50)
        # recruitment_system_btn.clicked.connect(self.open_recruitment_system)
        # tools_layout.addWidget(recruitment_system_btn)
        
        # 添加间距
        tools_layout.addStretch()
        
        main_layout.addLayout(tools_layout)
        
        # 状态栏
        self.statusBar().showMessage("就绪")
        
        # 版权信息
        copyright_label = QLabel("版权所有 © 玉师人事处")
        copyright_label.setAlignment(Qt.AlignCenter)
        main_layout.addWidget(copyright_label)
        
    def open_text_joiner(self):
        """打开文本连接工具"""
        self.text_joiner_window = TextJoinerUI()
        self.text_joiner_window.show()
        self.statusBar().showMessage("已启动文本连接工具")
        
    def open_word_table(self):
        """打开Word表格生成工具"""
        self.word_table_window = WordTableGeneratorUI()
        self.word_table_window.show()
        self.statusBar().showMessage("已启动Word表格生成工具")
        
    def open_recruitment_system(self):
        """打开招聘管理系统"""
        self.recruitment_system_window = RecruitmentSystem()
        self.recruitment_system_window.show()
        self.statusBar().showMessage("已启动招聘管理系统")


def main():
    app = QApplication(sys.argv)
    window = MainWindowUI()
    apply_stylesheet(app, theme='dark_lightgreen.xml', invert_secondary=False)
    window.show()
    sys.exit(app.exec())


if __name__ == '__main__':
    main()